Skip to content

PERF: Reduce verbosity of itk::GaussianOperator warning#3423

Merged
tbirdso merged 1 commit intoInsightSoftwareConsortium:masterfrom
tbirdso:gaussian-debug-printout
May 16, 2022
Merged

PERF: Reduce verbosity of itk::GaussianOperator warning#3423
tbirdso merged 1 commit intoInsightSoftwareConsortium:masterfrom
tbirdso:gaussian-debug-printout

Conversation

@tbirdso
Copy link
Contributor

@tbirdso tbirdso commented May 12, 2022

itk::GaussianOperator can be set with a MaximumKernelWidth parameter
such that a kernel that would otherwise overflow this size is cropped to
the maximum width. Cropping to the set maximum width happens frequently
in cases such as Gaussian blurring for multiscale pyramid generation and
is expected behavior, but the previous warning message makes it seem
like a failure case. This commit reduces the verbosity of the message
from a warning to a debug printout so that developers can get insights
into kernel cropping when needed, but are not alarmed by default warning
printouts.

Previous behavior: Warning whenever Gaussian kernel is correctly truncated to user specifications.

WARNING: In C:\P\IPP\ITK-source\ITK\Modules\Core\Common\include\itkGaussianOperator.hxx, line 57
GaussianOperator (000000C7587FC630): Kernel size has exceeded the specified maximum width of 32 and has been truncated to 33 elements. You can raise the maximum width using the SetMaximumKernelWidth method.

New behavior: No printout unless explicitly enabled.

PR Checklist

Refer to the ITK Software Guide for
further development details if necessary.

`itk::GaussianOperator` can be set with a `MaximumKernelWidth` parameter
such that a kernel that would otherwise overflow this size is cropped to
the maximum width. Cropping to the set maximum width happens frequently
in cases such as Gaussian blurring for multiscale pyramid generation and
is expected behavior, but the previous warning message makes it seem
like a failure case. This commit reduces the verbosity of the message
from a warning to a debug printout so that developers can get insights
into kernel cropping when needed, but are not alarmed by default warning
printouts.
@tbirdso tbirdso requested review from hjmjohnson and thewtex May 12, 2022 17:38
@github-actions github-actions bot added area:Core Issues affecting the Core module type:Performance Improvement in terms of compilation or execution time labels May 12, 2022
@tbirdso tbirdso merged commit c60f675 into InsightSoftwareConsortium:master May 16, 2022
@Leengit
Copy link
Contributor

Leengit commented May 17, 2022

In case it is related, ... I am now getting an error message in the master branch:

Building CXX object Modules/Registration/Common/test/CMakeFiles/ITKRegistrationCommonTestDriver.dir/itkMultiResolu
tionImageRegistrationMethodTest_1.cxx.o
FAILED: Modules/Registration/Common/test/CMakeFiles/ITKRegistrationCommonTestDriver.dir/itkMultiResolutionImageRegistration
MethodTest_1.cxx.o
[munch]
In file included from ~/git/ITK/Modules/Core/Common/include/itkLightObject.h:21,
                 from ~/git/ITK/Modules/Core/Common/include/itkObject.h:31,
                 from ~/git/ITK/Modules/Core/Transform/include/itkTransformBase.h:23,
                 from ~/git/ITK/Modules/Core/Transform/include/itkTransform.h:22,
                 from ~/git/ITK/Modules/Core/Transform/include/itkBSplineBaseTransform.h:22,
                 from ~/git/ITK/Modules/Registration/Common/include/itkImageToImageMetric.h:21,
                 from ~/git/ITK/Modules/Registration/Common/include/itkMutualInformationImageToImageMetric.h:21,
                 from ~/git/ITK/Modules/Registration/Common/test/itkMultiResolutionImageRegistrationMethodTest_1.cxx:19:
~/git/ITK/Modules/Core/Common/include/itkGaussianOperator.hxx: In instantiation of ‘typename itk::GaussianOperator<TPixel, VDimension, TAllocator>::Superclass::CoefficientVector itk::GaussianOperator<TPixel, VDimension, TAllocator>::GenerateCoefficients() [with TPixel = float; unsigned int VDimension = 3; TAllocator = itk::NeighborhoodAllocator<float>; typename itk::GaussianOperator<TPixel, VDimension, TAllocator>::Superclass::CoefficientVector = std::vector<double>]’:
~/git/ITK/Modules/Core/Common/include/itkGaussianOperator.hxx:26:1:   required from here
~/git/ITK/Modules/Core/Common/include/itkMacro.h:489:17: error: ‘class itk::GaussianOperator<float, 3, itk::NeighborhoodAllocator<float> >’ has no member named ‘GetDebug’
  489 |       if (this->GetDebug() && itk::Object::GetGlobalWarningDisplay())          \
      |           ~~~~~~^~~~~~~~
~/git/ITK/Modules/Core/Common/include/itkGaussianOperator.hxx:55:7: note: in expansion of macro ‘itkDebugMacro’
   55 |       itkDebugMacro(<< "Kernel size has exceeded the specified maximum width of " << m_MaximumKernelWidth
      |       ^~~~~~~~~~~~~
~/git/ITK/Modules/Core/Common/include/itkGaussianOperator.hxx: In instantiation of ‘typename itk::GaussianOperator<TPixel, VDimension, TAllocator>::Superclass::CoefficientVector itk::GaussianOperator<TPixel, VDimension, TAllocator>::GenerateCoefficients() [with TPixel = double; unsigned int VDimension = 3; TAllocator = itk::NeighborhoodAllocator<double>; typename itk::GaussianOperator<TPixel, VDimension, TAllocator>::Superclass::CoefficientVector = std::vector<double>]’:
~/git/ITK/Modules/Core/Common/include/itkGaussianOperator.hxx:26:1:   required from here
~/git/ITK/Modules/Core/Common/include/itkMacro.h:489:17: error: ‘class itk::GaussianOperator<double, 3, itk::NeighborhoodAllocator<double> >’ has no member named ‘GetDebug’
  489 |       if (this->GetDebug() && itk::Object::GetGlobalWarningDisplay())          \
      |           ~~~~~~^~~~~~~~
~/git/ITK/Modules/Core/Common/include/itkGaussianOperator.hxx:55:7: note: in expansion of macro ‘itkDebugMacro’

@tbirdso
Copy link
Contributor Author

tbirdso commented May 17, 2022

It certainly appears related. Interesting that this did not show up in CI. @Leengit could you please share details on your build platform?

@Leengit
Copy link
Contributor

Leengit commented May 17, 2022

Linux 5.13.0-41-generic #46~20.04.1-Ubuntu SMP Wed Apr 20 13:16:21 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
gcc (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0
ninja 1.10.0

@tbirdso
Copy link
Contributor Author

tbirdso commented May 17, 2022

Thank you, on review I am also able to see failures in CDash Expected Nightly Builds. My guess is that this means itkDebugMacro is only valid in objects inheriting from a certain base, perhaps ProcessObject? Maybe I missed something in documentation?

I will open an issue to track. If we can't use debug printouts here I would be in favor of removing the warning message entirely. It could be useful in certain scenarios where the user is unaware of a default truncation parameter, but in general it is simply informing the user that execution is proceeding according to design.

@Leengit
Copy link
Contributor

Leengit commented May 17, 2022

Perhaps a quick, sloppy fix to get the master branch working again. And an issue that asks that it be fixed more properly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:Core Issues affecting the Core module type:Performance Improvement in terms of compilation or execution time

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants